
package interface_grafica;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;

import listeners.ListenersTelaCarteiraSocios;
import listeners.ListenersTelaConsultaDoacao;
import listeners.ListenersTelaConsultaParceiro;
import listeners.ListenersTelaConsultaSocio;

public class TelaConsultaParceiro extends javax.swing.JPanel {

    private static TelaConsultaParceiro instance;

    public static TelaConsultaParceiro getInstance() {
        if (instance == null) {
            instance = new TelaConsultaParceiro();
        }
        return instance;
    }     
    
    public TelaConsultaParceiro() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        opcaoSexo = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabelaParceiros = new javax.swing.JTable();
        tipoBuscaParceiro = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        campoBuscaParceiro = new javax.swing.JTextField();
        botaoBuscaParceiro = new javax.swing.JButton();
        btCancelar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(1063, 557));

        tabelaParceiros.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        tabelaParceiros.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null}
            },
            new String [] {
                "ID", "Nome do Parceiro / Entidade"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
 
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabelaParceiros.getTableHeader().setReorderingAllowed(false);
        tabelaParceiros.getSelectionModel().addListSelectionListener(new ListenersTelaConsultaParceiro()); 
        
        jScrollPane1.setViewportView(tabelaParceiros);

        tipoBuscaParceiro.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        tipoBuscaParceiro.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ID", "CPF ou CNPJ", "Nome" }));

        jLabel6.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        jLabel6.setText("Filtrar por");

        campoBuscaParceiro.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N

        botaoBuscaParceiro.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        botaoBuscaParceiro.setText("Pesquisar");

        btCancelar.setText("Cancelar");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setText("Consulta de Parceiros");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btCancelar)
                .addGap(80, 80, 80))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(87, 87, 87)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tipoBuscaParceiro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoBuscaParceiro)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botaoBuscaParceiro))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 823, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(434, 434, 434)
                        .addComponent(jLabel1)))
                .addContainerGap(153, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 81, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tipoBuscaParceiro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(campoBuscaParceiro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(botaoBuscaParceiro))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btCancelar)
                .addGap(47, 47, 47))
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoBuscaParceiro;
    private javax.swing.JButton btCancelar;
    private javax.swing.JTextField campoBuscaParceiro;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.ButtonGroup opcaoSexo;
    private javax.swing.JTable tabelaParceiros;
    private javax.swing.JComboBox tipoBuscaParceiro;
    // End of variables declaration//GEN-END:variables

    public JButton getBotaoBuscaParceiro() {
        return botaoBuscaParceiro;
    }

    public JButton getBtCancelar() {
        return btCancelar;
    }

    public String getCampoBuscaParceiro() {
        return campoBuscaParceiro.getText();
    }

    public ButtonGroup getOpcaoSexo() {
        return opcaoSexo;
    }

    public JTable getTabelaParceiros() {
        return tabelaParceiros;
    }

    public JComboBox getTipoBuscaParceiro() {
        return tipoBuscaParceiro;
    }
    
    
    public DefaultTableModel getDtm() {

  		DefaultTableModel dtm = (DefaultTableModel) tabelaParceiros.getModel();

  		return dtm;
  	}
      
     public void limpaDtm(){		
  		getDtm().setNumRows(0);
  	}
    

}
